//
//  UserDataViewController.m
//  享动
//
//  Created by darker on 16/4/9.
//  Copyright © 2016年 HHUI. All rights reserved.
//

#import "UserDataViewController.h"
#import "UserViewController.h"

@interface UserDataViewController ()
@property (weak, nonatomic) IBOutlet UIView *backView;

@property (weak, nonatomic) IBOutlet UIScrollView *backScrollView;

@property (weak, nonatomic) IBOutlet UIImageView *backImageView;

// 用户头像
@property (weak, nonatomic) IBOutlet UIImageView *userHeadImageView;
// 编辑button
@property (weak, nonatomic) IBOutlet UIButton *editButton;
// 用户昵称
@property (weak, nonatomic) IBOutlet UILabel *userName;



@end

@implementation UserDataViewController

- (void)viewDidLoad {
    [super viewDidLoad];
        
    _backScrollView.frame = CGRectMake(0, 0, KWIDTH, 250);
    _backScrollView.contentOffset = CGPointMake(0, 0);
    _backScrollView.contentSize = CGSizeMake(KWIDTH * 2, 250);
    _backScrollView.showsHorizontalScrollIndicator = NO;
    _backScrollView.showsVerticalScrollIndicator = NO;
    _backScrollView.pagingEnabled = YES;
    _backScrollView.bounces = NO;
    self.automaticallyAdjustsScrollViewInsets = NO;
    
    _backView.frame = CGRectMake(0, 0, KWIDTH, 250);
    
    _backImageView.frame = CGRectMake(0, 64, KWIDTH * 2, 250);
    _backImageView.image = [UIImage imageNamed:@"view"];
    
    _userHeadImageView.frame = CGRectMake(10, 150, 50, 50);
    _userHeadImageView.layer.cornerRadius = 25;
    _userHeadImageView.image = [UIImage imageWithData:[[NSUserDefaults standardUserDefaults] objectForKey:@"headImage"]];
    _userHeadImageView.clipsToBounds = YES;
    _userHeadImageView.backgroundColor = [UIColor grayColor];
    
    _userName.frame = CGRectMake(65, 165, 150, 20);
    _userName.text = [[NSUserDefaults standardUserDefaults] objectForKey:@"userName"];
    _userName.font = [UIFont systemFontOfSize:14];
    
    _editButton.frame = CGRectMake(KWIDTH - 60, 64 + 50, 50, 20);
    _editButton.titleLabel.textColor = [UIColor blueColor];
    _editButton.layer.cornerRadius = 10;
    _editButton.layer.borderWidth = 0.3;
    [_editButton addTarget:self action:@selector(editButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    
    
}

- (void)back
{
    // 创建CATransition对象
    CATransition *animation = [CATransition animation];
    
    //设置运动时间
    animation.duration = 1;
    
    //设置运动type
    animation.type = kCATransitionFromLeft;
    
    //设置运动速度
    animation.timingFunction = UIViewAnimationOptionCurveEaseInOut;
    
    [self.navigationController.view.layer addAnimation:animation forKey:nil];
    
    [self.navigationController popViewControllerAnimated:YES];
}

#pragma mark --- 点击编辑button跳转 --- 
- (void)editButtonAction:(UIButton *)sender
{
    // 创建CATransition对象
    CATransition *animation = [CATransition animation];
    
    //设置运动时间
    animation.duration = 1;
    
    //设置运动type
    animation.type = kCATransitionFromRight;
    
    //设置运动速度
    animation.timingFunction = UIViewAnimationOptionCurveEaseInOut;
    
    [self.navigationController.view.layer addAnimation:animation forKey:nil];
    
    UserViewController *userTableVc = [[UserViewController alloc] initWithNibName:@"User" bundle:[NSBundle mainBundle]];
    
    [self.navigationController pushViewController:userTableVc animated:YES];
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
